import styled from 'styled-components';

import { SimpleVTable } from '@/components/table';
import { ConnectorDatabaseType } from '@/services';

export const HistorySqlList = (props: {
    dbType: ConnectorDatabaseType,
    action: (sql: string, index: number) => JSX.Element,
}) => {

    const sqlList: Array<{ dbType: string, sql: string, create_at: number }> = [];

    return (
        <SimpleVTable
            columns={[{
                name: '序号',
            },
            {
                name: 'SQL',
                size: 600
            }, {
                name: '时间',
            }, {
                name: '操作',
                size: 200,
                render: (record: Array<any>) => {
                    console.log(record);
                    return props.action(record[1], record[0]);
                }
            }]}
            data={
                sqlList.filter((item: any) => item.dbType === props.dbType).map((item: any, index) => {
                    console.log(item);
                    return [index, item.sql, item.create_at];
                }).reverse()}
        ></SimpleVTable>
    );
}